<template>
  <div>
    <div class="loginbg"></div>
    <div class="container">
      <div class="line bouncein">
        <div class="xs6 xm4 xs3-move xm4-move">
          <div style="height:150px;"></div>
          <div class="media media-y margin-big-bottom"></div>
          <div class="panel loginbox">
            <div class="text-center margin-big padding-big-top">
              <h1 style="color:white">欢迎使用天府闪送后台管理系统</h1>
            </div>
            <div class="panel-body" style="padding:30px; padding-bottom:10px; padding-top:10px;">
              <div class="form-group">
                <div class="field field-icon-right">
                  <input type="text" class="input input-big" v-model="account" placeholder="登录账号" />
                  <span class="icon icon-user margin-small"></span>
                </div>
              </div>
              <div class="form-group">
                <div class="field field-icon-right">
                  <input
                    type="password"
                    class="input input-big"
                    v-model="password"
                    placeholder="登录密码"
                  />
                  <span class="icon icon-key margin-small"></span>
                </div>
              </div>
            </div>
            <div style="padding:30px;">
              <input
                type="button"
                class="button button-block bg-main text-big input-big"
                value="登录"
                @click="login"
              />
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import Axios from "axios";
import Qs from "qs";
export default {
  data() {
    return {
      account: "",
      password: "",
    };
  },
  methods: {
    login() {
      if ((this.account.trim() == "")) {
        this.$message.warning("请输入账号");
      } else {
        if ((this.password.trim() == "")) {
          this.$message.warning("请输入密码");
        } else {
          Axios.post("/tfss/admin/login", {
            account: this.account,
            password: this.password,
          }).then((r) => {
            if (r.data.code === 200) {
              localStorage.setItem("token", r.data.data);
              localStorage.setItem("account", this.account);
              location.href = "/";
            } else if (r.data.code === 700) {
              this.$message.error("账号不存在");
            } else if (r.data.code === 701) {
              this.$message.error("账号被冻结");
            } else if (r.data.code === 702) {
              this.$message.error("密码错误");
            } else if (r.data.code === 500) {
              this.$message.error("系统繁忙，请稍后再试");
            }
          });
        }
      }
    },
  },
};
</script>

<style scoped>
</style>